__author__ = 'chenglin'
from hashlib import md5
from app import db

#
# class User(db.Model):
#     id = db.Column(db.Integer, primary_key=True)
#     nickname = db.Column(db.String(64), index=True, unique=True)
#     email = db.Column(db.String(120), index=True, unique=True)
#     posts = db.relationship('Post', backref='author', lazy='dynamic')
#     about_me = db.Column(db.String(140))
#     last_seen = db.Column(db.DateTime)
#
#     def is_authenticated(self):
#         return True
#
#     def is_active(self):
#         return True
#
#     def is_anonymous(self):
#         return False
#
#     def get_id(self):
#         try:
#             return unicode(self.id)  # python 2
#         except NameError:
#             return str(self.id)  # python 3
#
#     def avatar(self, size):
#         return 'http://www.gravatar.com/avatar/%s?d=mm&s=%d' % \
#             (md5(self.email.encode('utf-8')).hexdigest(), size)
#
#     def __repr__(self):
#         return '<User %r>' % (self.nickname)
#
#
# class Post(db.Model):
#     id = db.Column(db.Integer, primary_key=True)
#     body = db.Column(db.String(140))
#     timestamp = db.Column(db.DateTime)
#     user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
#
#     def __repr__(self):
#         return '<Post %r>' % (self.body)


class Menu(db.Model):
    __tablename__ = 'TB_IM_MENU'

    MENU_ID = db.Column(db.Integer, primary_key=True)
    P_MENU_ID = db.Column(db.String(140))
    MOD_ID = db.Column(db.String(140))
    MENU_NAME = db.Column(db.String(100))
    SHOW_CONT = db.Column(db.String(500))
    IS_BIND = db.Column(db.Boolean)
    MENU_DESC = db.Column(db.String(500))
    STATE = db.Column(db.String(8),server_default='10A')
    STATE_DATE = db.Column(db.DateTime)
    ORDER_ID = db.Column(db.String(100))
    MENU_TYPE = db.Column(db.Integer)
    HREF_ADDR = db.Column(db.String(200))

    def __repr__(self):
        return '<Menu %r>' % (self.MENU_ID)